package com.字符串中第一个不重复的字符下标;

import java.util.HashMap;

class Solution {
    public int firstUniqChar(String s) {
        int temp[] = new int[s.length()];
        HashMap<Character,Integer> hs = new HashMap<Character,Integer>();
        for(int i=0;i<s.length();i++){
            if(!hs.containsKey(s.charAt(i))){
                hs.put(s.charAt(i),1);
                
            }
            else{
                hs.put(s.charAt(i),hs.get(s.charAt(i))+1);
            }
            System.out.println(hs);
        }
        
        for(int i=0;i<s.length();i++){
            if(hs.get(s.charAt(i))==1)
                return i;
        }
        return -1;
    }
}
